package com.dongdongshop.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.domain.DataResult;
import com.dongdongshop.em.DataResultEnum;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.service.TbSellerService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("SellerController")
@Controller
public class SellerController {

    @Reference
    private TbSellerService tbSellerService;

    @RequestMapping("Toseller")
    public String Toseller(){
        return "admin/sellers";
    }

    @RequestMapping("getToshow")
    @ResponseBody
    public DataResult getToshow(){
        List<TbSeller> selectss = tbSellerService.selectss();
        return DataResult.buildDataResult(DataResultEnum.SUCCESS).setData(selectss);
    }

    @RequestMapping("selectByid")
    @ResponseBody
    public DataResult selectByid(String sellerId){
        TbSeller tbSeller = tbSellerService.selectByid(sellerId);
        return DataResult.buildDataResult(DataResultEnum.SUCCESS).setData(tbSeller);
    }

    @RequestMapping("updateSeller")
    @ResponseBody
    public DataResult updateSeller(String sellerId,String status){
        Boolean b = tbSellerService.updata(sellerId,status);
        if(b){
            return DataResult.buildDataResult(DataResultEnum.SUCCESS);
        }
        return DataResult.buildDataResult(DataResultEnum.ERROR);
    }
}
